<?php
$column_full = array(
	0 => "<div class='col_4'>ID</div>",
	1 => "<div class='col_2'>Họ tên</div>",
	2 => "<div class='col_1'>Email</div>",
	3 => "<div class='col_3'>Random key</div>",
	4 => "<div class='col_3'>Ngày đăng ký</div>",
	5 => "<div class='col_5'>Active</div>"
);
function btnCancel($page){
	header("location:administrator.php?p={$page}");
}
function column_general($p) {
	
	
}
function list_column($page, $id, $name, $email, $date_create, $active, $RandomKey){
	$date_create = date('d/m/Y', strtotime($date_create));
	return "
	<div class='row'>
		<div class='col_4'>{$id} &nbsp;</div>
		<div class='col_2'>{$name} &nbsp;</div>
		<div class='col_1'>{$email} &nbsp;</div>
		<div class='col_3'>{$RandomKey} &nbsp;</div>
		<div class='col_3'>{$date_create} &nbsp;</div>
		<div class='col_5'><a href='javascript:;' class='status' id='{$id}' page='{$page}' name='{$name}' set='{$active}'><img src='img/anhien_{$active}.gif' alt='' /></a> &nbsp;</div>
	</div>";
}
function phantrang($page,$max_results,$page_number,$search){
	global $sql;
	$from = (($page_number * $max_results) - $max_results);
	$link = "administrator.php?p={$page}&page_number=";
	$type = 6; //loại sql select $type = 6;
	$table = $page;
	$field = array('id');
	$sql->get_sql($type,$table,$field,$search);
	$qr = $sql->executable() or die ('<p class="error">Không truy vấn được</p>');
	$total = mysql_num_rows($qr);
	mysql_free_result($qr);
	
	$total_pages = ceil($total / $max_results);
	if($total_pages > 1){
		if($page_number > 1){
			$prev = ($page_number - 1);
			echo "<a href='{$link}{$prev}'>Trang trước</a>";
		}
		for($i = $page_number - 5; $i <= $page_number + 5 & $i <= $total_pages; $i++){
			if($page_number == $i){
				echo "<a href='{$link}{$i}' style='color:#F00; font-weight:bold; background-color:#ffffcc'>{$i}</a>";
			} elseif($i>0) {
				echo "<a href='{$link}{$i}'>{$i}</a>";
			}
		}
		if($page_number < $total_pages){
			$next = ($page_number + 1);
			echo "<a href='{$link}{$next}'>Trang sau</a>";
		}
	}
}